package work;

import org.openqa.selenium.WebElement;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.android.AndroidTouchAction;
import io.appium.java_client.touch.LongPressOptions;
import io.appium.java_client.touch.offset.ElementOption;

public class BaseAction {
	public AndroidDriver<AndroidElement> driver;
	public AndroidTouchAction action;
	public BaseAction(AndroidDriver<AndroidElement> driver) {
		this.driver=driver;
		this.action=new AndroidTouchAction(driver);
	}
//	点击
	public void click(WebElement elemnet) throws InterruptedException {
		elemnet.click();
		Thread.sleep(2000);
	}
//长按
	public void longPress(WebElement ele) throws InterruptedException{
    	LongPressOptions longPressOptions = LongPressOptions.longPressOptions();
		longPressOptions.withElement(ElementOption.element(ele));
		action.longPress(longPressOptions).perform();
		Thread.sleep(2000);
    }
//	添加文本
	public void type(WebElement element,String context) throws InterruptedException{
        element.sendKeys(context);
        Thread.sleep(2000);
	}
//	清除文本
	public void clear_text(WebElement element) throws InterruptedException {
		element.clear();
		Thread.sleep(2000);
	}

	
	
	
}
